package com.example4;

//线程转态测试
public class ThreadStateTest3 {
    public static void main(String[] args) throws InterruptedException {
        SubThread t = new SubThread();
        System.out.println(t.getName() + "状态" + t.getState());
        t.start();
//        判断当前线程是否不是死亡状态
        while (Thread.State.TERMINATED != t.getState()) {
            System.out.println(t.getName() + "状态" + t.getState());
            Thread.sleep(500);

        }
        System.out.println(t.getName() + "状态" + t.getState());


    }
}

class SubThread extends Thread {
    @Override
    public void run() {
        while (true) {
            for (int i = 0; i < 10; i++) {
                System.out.println("打印：" + i);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }
            break;
        }
    }
}
